<?php
/**
 * 家长模型
 */

namespace app\voip\func;


use app\voip\model\EPatriarch;

class PatriarchFunc
{
    /**
     * @param $data
     * @return false|int
     */
    static public function add($data)
    {
        $obj =new EPatriarch($data);
        return $obj->allowField(true)->save();
    }

    /**
     * @param $where
     * @param $data
     * @return false|int
     */
    static public function update($data, $where)
    {
        return EPatriarch::update($data,$where)->save();
    }
    /**
     * @param $data
     * @return array|false
     * @throws \Exception
     */
    static public function addAll($data)
    {
        $obj=new EPatriarch();
        return $obj->saveAll($data,false);
    }

    /**
     * @param $pid
     * @return array|false|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static public function getInfo($pid)
    {
        $obj = new EPatriarch();
        return $obj->alias('p1')->
        join('e_home_address h1','p1.id=h1.pid')->
        join('e_worksheet w1','p1.id=w1.up_id')->where('p1.id',$pid)->field('p1.*,h1.detailed_addr,w1.intro wintro')->find();
    }

}